rimage: manifest: Make "cold" section size 0 when not used#10612
rimage: manifest: Make "cold" section size 0 when not used#10612dbaluta wants to merge 1 commit intothesofproject:mainfrom
Conversation
There are some non-critical data and code sections that are kept in DRAM to be accessed and executed from there without being copied to SRAM. Such sections are marked as `detached` and linked into a separate "cold.mod" module. rimage considers zones starting at SOF_MODULE_DRAM_LINK_START to SOF_MODULE_DRAM_LINK_END to be cold and links them separately. On i.MX8MP for M7 support this overalps with ITCM/DTCM/OCRAM areas which causes boot problems. So, treat all sections as SRAM when CONFIG_COLD_STORE_EXECUTE_DRAM is not enabled by making DRAM link sections size equal to 0 in this case. Closes: thesofproject#10602 Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a boot problem on i.MX8MP (M7) where ITCM/DTCM/OCRAM memory sections were incorrectly treated as "detached" (cold/DRAM) by rimage, causing them to be omitted from the output image. The fix makes SOF_MODULE_DRAM_LINK_END equal to SOF_MODULE_DRAM_LINK_START (both 0) when CONFIG_COLD_STORE_EXECUTE_DRAM is not enabled, effectively collapsing the DRAM link range to empty and ensuring all sections are treated as SRAM.
Changes:
- When
CONFIG_COLD_STORE_EXECUTE_DRAMis disabled,SOF_MODULE_DRAM_LINK_ENDis defined asSOF_MODULE_DRAM_LINK_START(0), making the DRAM detection range empty. - When
CONFIG_COLD_STORE_EXECUTE_DRAMis enabled, behavior is unchanged (SOF_MODULE_DRAM_LINK_END= 0x08000000).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #if CONFIG_COLD_STORE_EXECUTE_DRAM | ||
| #define SOF_MODULE_DRAM_LINK_END 0x08000000 | ||
| #else | ||
| #define SOF_MODULE_DRAM_LINK_END SOF_MODULE_DRAM_LINK_START | ||
| #endif |
There was a problem hiding this comment.
The comment block above SOF_MODULE_DRAM_LINK_START (lines 253–258) only accurately describes the behavior when CONFIG_COLD_STORE_EXECUTE_DRAM is enabled. After this change, when the config is not enabled, SOF_MODULE_DRAM_LINK_END equals SOF_MODULE_DRAM_LINK_START (i.e., 0), making the DRAM link range empty and disabling detached-section treatment entirely. The comment should be updated to reflect this conditional behavior — for example, noting that when CONFIG_COLD_STORE_EXECUTE_DRAM is not set, the range is empty and no sections are treated as detached.
|
@dbaluta The change looks good, but CI fails, and I think I know why. That header that you're modifying is also included for rimage build and there |
|
@lyakh oh this is so unfortunate. Yes, I would also prefer same rimage for all architectures. Maybe add a runtime parameter to ignore detached sections. |
@dbaluta yep, I think that would be better, then we'd also need to change xtensa-build-zephyr.py to supply correct parameters. If you want to do that - I think that would be welcome, but since effectively rimage already is platform-dependent, I think as a bug-fix we can accept including autoconf.h |
I'm trying to figure out how to generate autoconf.h before building the rimage so I can include it. Looks like now the rimage is build first and then fw compilation starts later. |
|
@lyakh Using CONFIG_* from a generated header file based on platform config to compile rimage is complicated and error prone. I think the best course of action here is to make use of toml config files. Will send a patch with this idea. |
Btw, no objections if you want to ask copilot to change rimage from autotools to CMake if this makes things easier going forward. |
I think rimage is already using cmake, right? The point here is that we need the generated header file with config symbols (build-imx8m/zephyr/include/generated/zephyr/autoconf.h) before compiling rimage so that we can figure out platform config. So we need to do something like this:
This ping pong makes me think this solution is complicated. My approach right now is to use tools/rimage/config/ toml file maybe something like this: version = [1, 5] [adsp] OR myabe just use the machine name at runtime and figure out when to add the dram_link area. Anyhow, I'll investigate more not sure which solution would be faster to implement. |
@dbaluta interesting, when building SOF for Intel ADSP the xtensa-build-zephyr.py script among other things does:
So, if we wanted to build rimage after creating autoconf.h we'd have to execute step (2) without the signing step, then build rimage (1) and then run it to sign the image. So, yes, this looks like a rather intrusive change, agree. Otherwise, if you're considering adding this to toml, is it still easier than making it a run-time parameter for rimage? |
Runtime param looks the easiest approach: Please have a look #10624 |
There are some non-critical data and code sections that are kept in DRAM to be accessed and executed from there without being copyind to SRAM.
Such sections are marked as
detachedand linked into a separate "cold.mod" module.rimage considers zones starting at SOF_MODULE_DRAM_LINK_START to SOF_MODULE_DRAM_LINK_END to be cold and links them separately.
On i.MX8MP for M7 support this overalps with ITCM/DTCM/OCRAM areas which causes boot problems.
So, treat all sections as SRAM when CONFIG_COLD_STORE_EXECUTE_DRAM is not enabled by making DRAM link sections size equal to 0 in this case.
Closes: #10602